using UnityEngine;
using System.Collections;

public class crane : MonoBehaviour {
	
	Vector3 home;
	bool movingUp = false;
	bool movingDown = true;
	public float moveSpeed = 4;
	float moveDistance = 10;
	
	// Use this for initialization
	void Start () {
		home = transform.position;
	}
	
	// Update is called once per frame
	void Update () {
		
		if(transform.position.y > home.y){
			movingUp = false;
			movingDown = true;
			moveSpeed = Random.Range(2,5);
			
		}
		if(transform.position.y < home.y-moveDistance){
			movingUp = true;
			movingDown = false;
			moveSpeed = Random.Range(2,5);
		}
		if(movingUp){
			transform.Translate(Vector3.up * moveSpeed * Time.deltaTime,Space.World);
		}
		if (movingDown){
			transform.Translate(Vector3.down * moveSpeed * Time.deltaTime,Space.World);
		}
		//if(transform.position <= home && 
	}
}
